package com.changgou.search.listener;

import com.changgou.search.config.RabbitMQConfig;
import com.changgou.search.service.ESManagerService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component //bean对象，交由spring管理
public class GoodsUpListener {
    @Autowired
    ESManagerService esManagerService;
    //监听某个队列
    @RabbitListener(queues = RabbitMQConfig.SEARCH_ADD_QUEUE)
    public void receiveMessage(String spuId) {
        System.out.println("接收到消息为："+spuId);

        //查询相应数据，入es库
        esManagerService.importDataBySpuId(spuId);
    }
}